Repository navigation
Hand out narrow, expiring permissions instead of standing ones - #7
Merged
Merged
Conversation
--allow-peer says a sender may write here and keeps saying it until somebody edits the configuration. That is the right granularity for an operator with a handful of machines and the wrong one for anything that issues permissions per job: it cannot say this sender, into this directory, until this time. A grant is that narrower statement, signed by a key the daemon was told to trust and checked entirely offline -- no callback, no directory service. That is what lets something outside this daemon hand out permissions without speaking the wire protocol or linking this code: it runs `favonius-daemon grant`, which prints hex, and passes that to the sender. A grant names four things and the daemon checks all four. The sender, so a grant captured off the wire is useless to anyone who cannot also prove the identity it names. The destination daemon, because without it a permission to write to one machine would be accepted by every machine trusting the same anchor. A path prefix, applied after --dest-root confinement so it can only narrow what the machine's own policy already allows, and compared against the resolved absolute path so that `..` cannot do the work the check exists to prevent. And an expiry, which is the only revocation here: a grant cannot be recalled, it runs out, so the default is minutes. --trust-anchor may be repeated. That is deliberate and it is what makes rotating the signing key possible without a flag day: publish the new anchor, let daemons accept both, switch issuance, drop the retired one. With one anchor at a time, rotation means reconfiguring every daemon in an estate inside the same window. Expiry is checked once, at the handshake. Rechecking mid-transfer would kill a six-hour copy over a permission that was valid when it started and buy nothing, because the sender is bound to the session keys by then. A host whose clock is before 2020 has not set it, and every expiry check against such a clock answers "not expired" -- the wrong way to be wrong -- so grants are refused there with a message naming NTP rather than silently accepted. One hole found while testing this, and it predates grants. A successful transfer earned a 0-RTT session ticket, and a HELLO carrying a ticket took a branch that ran none of the authorisation checks. A sender authorised for one directory and five minutes could transfer once, then reconnect with the ticket and write anywhere under --dest-root for as long as it lived. The note in that branch is right that a resumed session inherits server authentication from the ticket -- the client chose to trust that daemon once -- but it does not follow in the other direction, because a ticket carries neither an expiry nor a path. A daemon enforcing any peer policy now refuses resumes and does not issue tickets at all, so the two ends agree about what is possible. Found by a test that transferred inside its grant and then wrote outside it and succeeded; that test is kept, and a second one names the mechanism directly. Refusals say so rather than going quiet. The path check happens after the manifest, so a violation used to leave the sender retransmitting into silence and failing with "deadline has elapsed" after thirty seconds, which sends its operator to look at a network that is working. It now fails in 72 ms against a bare ERROR carrying no reason, with the reason in the daemon's log where the operator who set the policy can read it and where it cannot be used to probe what is permitted. Verified end to end against a running daemon, asserting on the destination directory rather than on exit codes: a write inside the granted prefix lands; the same grant used for a path outside it writes nothing; a forged grant, one issued for another daemon, one issued for another sender and an expired one each write nothing; and a daemon that accepts grants but does not require them still serves a sender that brings none. 641 tests pass. Signed-off-by: Jimmy <jimbotonic@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--allow-peersays this sender may write here, and keeps saying it until somebody edits the configuration. Where permissions are handed out per job, that is the wrong granularity. A grant is the narrower statement — this sender, into this directory, until this time — signed by a key the daemon was told to trust and checked entirely offline.That offline property is what lets something outside the daemon issue permissions without speaking the wire protocol or linking this code: it runs
favonius-daemon grant, which prints hex, and hands that to the sender.What a grant binds, and why each part is there
--dest-rootconfinement, so it can only narrow what the machine's own policy already allows, and compared against the resolved absolute path so..cannot do the work the check exists to prevent.--trust-anchoris repeatable, which is what makes rotating the signing key possible without a flag day: publish the new anchor, let daemons accept both, switch issuance, drop the retired one.Expiry is checked once, at the handshake — rechecking mid-transfer would kill a six-hour copy over a permission that was valid when it started, and buy nothing, since the sender is bound to the session keys by then. A host whose clock is before 2020 has not set it, and every expiry check against such a clock answers "not expired"; grants are refused there with a message naming NTP rather than silently accepted.
A hole found while testing, which predates grants
A successful transfer earned a 0-RTT session ticket, and a HELLO carrying a ticket took a branch that ran none of the authorisation checks. A sender authorised for one directory and five minutes could transfer once, then reconnect with the ticket and write anywhere under
--dest-rootfor as long as it lived.The note in that branch is right that a resumed session inherits server authentication from the ticket — the client chose to trust that daemon once. It does not follow in the other direction: a ticket carries neither an expiry nor a path. A daemon enforcing any peer policy now refuses resumes and does not issue tickets at all, so both ends agree about what is possible.
Found by a test that transferred inside its grant, then wrote outside it, and succeeded. That test is kept; a second one names the mechanism directly.
Refusals say so
The path check happens after the manifest, so a violation used to leave the sender retransmitting into silence and failing with
deadline has elapsedafter 30s — pointing its operator at a network that is working. It now fails in 72 ms against a bareERRORcarrying no reason, with the reason in the daemon's log where it cannot be used to probe what is permitted.Verification
Against a running daemon, asserting on the destination directory rather than exit codes: a write inside the granted prefix lands; the same grant used outside it writes nothing; a forged grant, one for another daemon, one for another sender, and an expired one each write nothing; and a daemon that accepts grants without requiring them still serves a sender that brings none. 641 tests pass.